package com.hippo.javacore.javaiostream.iostream;

import java.io.DataInputStream;
import java.io.FileInputStream;

/**
 * @ClassName DataInputStreamOpt
 * @Description TODO 数据输入流操作类
 * @Author tangxl
 * @create 2023-04-07 10:18
 **/
public class DataInputStreamOpt {
    public static void main(String[] args) {
        try (
                // 创建一个数据字节输入流对象
                DataInputStream dis = new DataInputStream(new FileInputStream("study-commons/java-file-iostream/src/main/resources/file/a.txt"));
                ){
            // 读取数据, 读取的顺序要与写入的顺序一致
            int i = dis.readInt();
            System.out.println(i);
            double d = dis.readDouble();
            System.out.println(d);
            String s = dis.readUTF();
            System.out.println(s);
            boolean b = dis.readBoolean();
            System.out.println(b);
        }catch (Exception e) {
            
        }
    }
}
